<?php


/**
 * Radcodes - SocialEngine Module
 *
 * @category   Application_Extensions
 * @package    Badge
 * @copyright  Copyright (c) 2009-2010 Radcodes LLC (http://www.radcodes.com)
 * @license    http://www.radcodes.com/license/
 * @version    $Id$
 * @author     Vincent Van <vincent@radcodes.com>
 */
 
 
?>

<div class="headline">
  <h2>
    <?php echo $this->translate('Badges');?>
  </h2>
  <div class="tabs">
    <?php
      // Render the menu
      echo $this->navigation()
        ->menu()
        ->setContainer($this->navigation)
        ->render();
    ?>
  </div>
</div>

<div class='layout_right'>
  <?php echo $this->form->render($this) ?>
</div>

<div class='layout_middle badge_layout_middle'>
  
  <?php if( $this->keyword):?>
    <div class="badges_result_filter_details">

        <?php echo $this->translate('Showing awards posted with keyword %s', $this->htmlLink(
          $this->url(array('keyword'=>$this->keyword), 'badge_award_browse', true),
          $this->keyword
        ));?>
      <?php echo $this->htmlLink(array('route'=>'badge_award_browse'), $this->translate('(x)'))?>
    </div>
  <?php endif; ?>
  
  <?php if( $this->paginator->getTotalItemCount() > 0 ): ?>
      <ul class='badges_awards_browse'>
        <?php foreach ($this->paginator as $award): ?>
          <?php 
            $badge = $award->getBadge(); 
            $user = $award->getUser();
            $user_total_awards = Engine_Api::_()->badge()->countUserActiveAwards($user);
          ?>
        <li>
          <div class='badge_award_user_photo'>
            <?php echo $this->htmlLink($user->getHref(), $this->itemPhoto($user, 'thumb.icon'));?>
          </div>
          <div class='badge_award_user_info'>
            <div class='badge_award_user_info_title'>
              <?php echo $user->__toString(); ?>
            </div>
            <div class='badge_award_user_info_meta'>
              <?php echo $this->htmlLink(array('route'=>'badge_award_user','user_id'=>$award->user_id),
                $this->translate(array('%s award','%s awards',$user_total_awards), $user_total_awards)
              )?>
            </div>
          </div>
          <div class='badge_award_badge_photo'>
            <?php echo $this->htmlLink($badge->getHref(), $this->itemPhoto($badge, 'thumb.icon'));?>
          </div>
          <div class='badge_award_info'>
            <div class='badge_award_title'>
              <?php echo $award->__toString(); ?>
            </div>
            <div class='badge_award_details'>
              <?php echo $this->translate('%1$s badge', $badge->__toString()); ?>
            </div>
            <div class='badge_award_meta'>
              <?php echo $this->timestamp($award->creation_date); ?>
              -
              <?php echo $this->translate(array("%s comment", "%s comments", $award->comment_count), $this->locale()->toNumber($award->comment_count)); ?>
              -
              <?php echo $this->translate(array('%1$s like', '%1$s likes', $award->like_count), $this->locale()->toNumber($award->like_count)); ?>
            </div>
          </div>
        </li>
        <?php endforeach; ?>
      </ul>
  <?php elseif($this->keyword): ?>
    <div class="tip">
      <span>
        <?php echo $this->translate('There are no awards with that criteria.');?>
      </span>
    </div>
  <?php else:?>
    <div class="tip">
      <span>
        <?php echo $this->translate('There are no awards posted yet.');?>
      </span>
    </div>
  <?php endif; ?>

    <?php echo $this->paginationControl($this->paginator, null, null, array(
      'query' => $this->formValues
    )); ?>    

</div>
